package com.yunxiao.cloud.web.task;

import com.yunxiao.cloud.common.util.HostUtil;
import com.yunxiao.cloud.job.controller.ScheduleJobController;
import com.yunxiao.cloud.job.entity.RequestScheduleModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @description: AfterStartRunner
 * @date: 2019/12/20 14:12
 * @author: yunxiao
 * @version: 1.0
 */
@Component
@Order(1)
public class AfterStartRunnerTask implements CommandLineRunner {

    @Autowired
    ScheduleJobController scheduleJobController;

    @Override
    public void run(String... args) throws Exception {

        Thread.sleep(2000L);
        String ip = HostUtil.getLocalHost();

        RequestScheduleModel requestScheduleModel = new RequestScheduleModel();
        requestScheduleModel.setBeanName("getTimeTestTask");
        requestScheduleModel.setJobId("test0011");
        requestScheduleModel.setStatus(0);
        requestScheduleModel.setCronExpression("0 0/1 * * * ?");

        scheduleJobController.insertJob(requestScheduleModel);

    }
}
